package Task;

import com.test.batch.UserService;
import com.test.model.User;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;

import java.util.List;

public class SaveUserTask implements  Runnable{
    private UserService userService;
    private List<User>  userList;

    public SaveUserTask(UserService userService, List<User> list) {
        this.userService = userService;
        this.userList = list;

    }
    @Override
    public void run() {
        try {
            long start = System.currentTimeMillis();
            System.out.println("start" + start);
           // System.out.println(userList);
            userService.saveBatch(userList);
            long end = System.currentTimeMillis();
            System.out.println("end" + end);
            System.out.println(Thread.currentThread().getName() +"" +  "计算时间为： " + (end - start));
        }catch (Throwable e) {
            throw e;
        }
    }
}
